package com.ttt.adbgui.function;

import com.ttt.adbgui.jcomp.JFrameComponent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.swing.*;

@Component
@Slf4j
public class ReplaceComponent {

    @Autowired
    private JFrameComponent jFrameComponent;

    public void setVisibleFalse(){
        JDesktopPane rightDesktopPane = jFrameComponent.getRightDesktopPane();
        java.awt.Component[] components = rightDesktopPane.getComponents();
        for (int i = 0; i < components.length; i++) {
            components[i].setVisible(false);
        }
    }

    public void setLeftPanelFalse(){
        JDesktopPane leftDesktopPane = jFrameComponent.getLeftDesktopPane();
        java.awt.Component[] components = leftDesktopPane.getComponents();
        for (int i = 0; i < components.length; i++) {
            components[i].setBackground(UIManager.getColor("ComboBox.buttonHighlight"));
        }
    }

    // rightDesktopPane内组件进行显示
    public void setRightDesktopPaneTrue(){
        JDesktopPane rightDesktopPane = jFrameComponent.getRightDesktopPane();
        java.awt.Component[] components = rightDesktopPane.getComponents();
        for (int i = 0; i < components.length; i++) {
            components[i].setVisible(true);
        }
    }
}
